home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d18 / opbonus.arc / CALIBRAT.ARC / CALIBRAT.PAS < prev    next >
Pascal/Delphi Source File  |  1991-03-20  |  19KB  |  695 lines

  1. {$V-,F+}
  2. {$I OPDEFINE.INC}
  3. program Calibrate;
  4.   {-Define and edit BasePrinters}
  5.  
  6. uses
  7.   Dos,
  8.   OpInline,
  9.   OpString,
  10.   OpRoot,
  11.   OpCrt,
  12.   OpDos,
  13.   OpColor,
  14.   {$IFDEF UseMouse}
  15.   OpMouse,
  16.   {$ENDIF}
  17.   OpAbsFld,
  18.   OpFrame,
  19.   OpCmd,
  20.   OpField,
  21.   OpWindow,
  22.   OpSEdit,
  23.   OpSelect,
  24.   OpEntry,
  25.   OpPrnLow;
  26.  
  27.   {$IFDEF UseMouse}
  28. const
  29.   MouseChar : Char = #04;
  30.   {$ENDIF}
  31.  
  32. const
  33.   EsColors : ColorSet = (
  34.     TextColor       : YellowOnBlue;       TextMono        : WhiteOnBlack;
  35.     CtrlColor       : YellowOnBlue;       CtrlMono        : WhiteOnBlack;
  36.     FrameColor      : CyanOnBlue;         FrameMono       : LtGrayOnBlack;
  37.     HeaderColor     : WhiteOnCyan;        HeaderMono      : BlackOnLtGray;
  38.     ShadowColor     : DkGrayOnBlack;      ShadowMono      : WhiteOnBlack;
  39.     HighlightColor  : WhiteOnRed;         HighlightMono   : BlackOnLtGray;
  40.     PromptColor     : LtGrayOnBlue;       PromptMono      : LtGrayOnBlack;
  41.     SelPromptColor  : LtGrayOnBlue;       SelPromptMono   : LtGrayOnBlack;
  42.     ProPromptColor  : DkGrayOnBlue;       ProPromptMono   : BlackOnBlack;
  43.     FieldColor      : YellowOnBlue;       FieldMono       : LtGrayOnBlack;
  44.     SelFieldColor   : BlueOnCyan;         SelFieldMono    : WhiteOnBlack;
  45.     ProFieldColor   : DkGrayOnBlue;       ProFieldMono    : BlackOnBlack;
  46.     ScrollBarColor  : CyanOnBlue;         ScrollBarMono   : LtGrayOnBlack;
  47.     SliderColor     : CyanOnBlue;         SliderMono      : WhiteOnBlack;
  48.     HotSpotColor    : BlackOnCyan;        HotSpotMono     : BlackOnLtGray;
  49.     BlockColor      : YellowOnCyan;       BlockMono       : WhiteOnBlack;
  50.     MarkerColor     : WhiteOnCyan;        MarkerMono      : BlackOnLtGray;
  51.     DelimColor      : YellowOnBlue;       DelimMono       : WhiteOnBlack;
  52.     SelDelimColor   : BlueOnCyan;         SelDelimMono    : WhiteOnBlack;
  53.     ProDelimColor   : YellowOnBlue;       ProDelimMono    : WhiteOnBlack;
  54.     SelItemColor    : YellowOnCyan;       SelItemMono     : BlackOnLtGray;
  55.     ProItemColor    : LtGrayOnBlue;       ProItemMono     : LtGrayOnBlack;
  56.     HighItemColor   : WhiteOnBlue;        HighItemMono    : WhiteOnBlack;
  57.     AltItemColor    : WhiteOnBlue;        AltItemMono     : WhiteOnBlack;
  58.     AltSelItemColor : WhiteOnCyan;        AltSelItemMono  : BlackOnLtGray;
  59.     FlexAHelpColor  : WhiteOnBlue;        FlexAHelpMono   : WhiteOnBlack;
  60.     FlexBHelpColor  : WhiteOnBlue;        FlexBHelpMono   : WhiteOnBlack;
  61.     FlexCHelpColor  : LtCyanOnBlue;       FlexCHelpMono   : BlackOnLtGray;
  62.     UnselXrefColor  : YellowOnBlue;       UnselXrefMono   : LtBlueOnBlack;
  63.     SelXrefColor    : WhiteOnCyan;        SelXrefMono     : BlackOnLtGray;
  64.     MouseColor      : WhiteOnRed;         MouseMono       : BlackOnLtGray
  65.   );
  66.  
  67. {Entry field constants}
  68. const
  69.   idUseBiosServices      = 0;
  70.   idPrinterName          = 1;
  71.   idLPTNumber            = 2;
  72.   idPrinterTestNo        = 3;
  73.  
  74. {Help index constants}
  75. const
  76.   hiUseBiosServices      = 1;
  77.   hiPrinterName          = 2;
  78.   hiLPTNumber            = 3;
  79.   hiPrinterTestNo        = 4;
  80.  
  81.  
  82. var
  83.   NormalAttr, HelpAttr, HelpLine     : Byte;
  84.   ES     : EntryScreen;
  85.   Status : Word;
  86.   Mask, HighScore : Byte;
  87.   UserRec     : record
  88.              PrinterName          : string[32];
  89.              UseBiosServices      : Boolean;
  90.              LPTNumber            : Byte;
  91.              PrinterTestNo        : Byte;
  92.            end;
  93.  
  94. type
  95.   Str80            = String[80];
  96.   PrinterDesc      =
  97.     record
  98.       Name         : Str80;
  99.       PType        : PrnType;
  100.     end;
  101.   TestType         = (Online, Offline, OutOfPaper, PoweredOff);
  102.   ResultType       = Array[TestType] of Byte;
  103.  
  104. const
  105.   TestPrompt       : Array[TestType] of Str80 =
  106.     ('Insure the printer is online and ready with paper loaded',
  107.      'Take the printer offline',
  108.      'Remove the paper from the printer',
  109.      'Turn the printer off');
  110.  
  111.   Title            =
  112. 'Calibrate - Creates BasePrinter Streams - by TurboPower Software';
  113.  
  114.   OnlineWeight     = 50;
  115.   OfflineWeight    = 25;
  116.   PaperWeight      = 20;
  117.   OffWeight        = 5;
  118.  
  119.   PrX1             = 10;
  120.   PrY1             = 20;
  121.   PrX2             = 70;
  122.  
  123.   StreamFileName   : String[79] = '';
  124.  
  125.   function GetKey : Word;
  126.   begin
  127.     GetKey := OpCrt.ReadKeyWord;
  128.   end;
  129.  
  130.   procedure DisplayErrorMsg(Msg : string);
  131.     {-Display an error message}
  132.   var
  133.     W, CursorSL, CursorXY : Word;
  134.     P : Pointer;
  135.   begin
  136.     {try to save screen}
  137.     if not SaveWindow(1, HelpLine, ScreenWidth, HelpLine, True, P) then begin
  138.       RingBell;
  139.       Exit;
  140.     end;
  141.  
  142.     {Store cursor position and shape, then make it a fat cursor}
  143.     GetCursorState(CursorXY, CursorSL);
  144.     FatCursor;
  145.  
  146.     {add to default message, if possible}
  147.     if Length(Msg) < 60 then
  148.       Msg := Msg+'. Press any key...';
  149.  
  150.     {display error message and ring bell}
  151.     FastWrite(Center(Msg, ScreenWidth), HelpLine, 1, HelpAttr);
  152.     RingBell;
  153.  
  154.     {flush keyboard buffer}
  155.     while KeyPressed do
  156.       W := GetKey;
  157.  
  158.     {wait for keypress}
  159.     W := GetKey;
  160.  
  161.     {Restore cursor position and shape}
  162.     RestoreCursorState(CursorXY, CursorSL);
  163.  
  164.     {restore screen}
  165.     RestoreWindow(1, HelpLine, ScreenWidth, HelpLine, True, P);
  166.   end;
  167.  
  168. procedure PreEdit(ESP : EntryScreenPtr);
  169.   {-Called just before a field is edited}
  170. var
  171.   S : String[80];
  172.   A : Byte;
  173. begin
  174.   with ESP^ do
  175.     case GetCurrentID of
  176.       idUseBiosServices      :
  177.         S := 'T to use BIOS Services, F to use DOS Services';
  178.       idPrinterName          :
  179.         S := 'Enter the name of the file or device to send output to';
  180.       idLPTNumber            :
  181.         S := 'Enter LPT Number (1, 2, or 3)';
  182.       idPrinterTestNo        :
  183.         S := 'Enter printer test number (F10 for auto test selection)';
  184.       else
  185.         S := '';
  186.     end;
  187.   FastWrite(Center(S, ScreenWidth), HelpLine, 1, HelpAttr);
  188. end;
  189.  
  190. procedure PostEdit(ESP : EntryScreenPtr);
  191.   {-Called just after a field has been edited}
  192. begin
  193.   with ESP^, UserRec do
  194.     case GetCurrentID of
  195.       idUseBiosServices      : begin
  196.                                  if UseBiosServices then begin
  197.                                    ChangeProtection(idLPTNumber, False);
  198.                                    ChangeProtection(idPrinterTestNo, False);
  199.                                    ChangeProtection(idPrinterName, True);
  200.                                  end
  201.                                  else begin
  202.                                    ChangeProtection(idLPTNumber, True);
  203.                                    ChangeProtection(idPrinterTestNo, True);
  204.                                    ChangeProtection(idPrinterName, False);
  205.                                  end;
  206.                                  DrawField(idPrinterName);
  207.                                  DrawField(idLPTNumber);
  208.                                  DrawField(idPrinterTestNo);
  209.                                end;
  210.       idPrinterName          : ;
  211.       idLPTNumber            : ;
  212.       idPrinterTestNo        : ;
  213.     end;
  214. end;
  215.  
  216. procedure DisplayHelp(UnitCode : Byte; IdPtr : Pointer; HelpIndex : Word);
  217.   {-Display context sensitive help}
  218. begin
  219. end;
  220.  
  221. procedure IncChoice(var Value; ID : Word; Factor : Integer; var St : string);
  222.   {-Increment a multiple choice field value and convert it to a string}
  223. begin
  224. end;
  225.  
  226. procedure ErrorHandler(UnitCode : Byte; var ErrCode : Word; Msg : string);
  227.   {-Report errors}
  228. begin
  229.   DisplayErrorMsg(Msg);
  230. end;
  231.  
  232. procedure ClearHelpLine;
  233.  
  234. begin
  235.   FastWrite(CharStr(' ', ScreenWidth), HelpLine, 1, HelpAttr);
  236. end;
  237.  
  238. procedure WriteHelpLine(S : String);
  239.  
  240. begin
  241.   FastWrite(Center(S, ScreenWidth), HelpLine, 1, HelpAttr);
  242. end;
  243.  
  244. procedure Abort(S : String);
  245.  
  246. begin
  247.   GotoXY(1,25);
  248.   WriteLn(S);
  249.   RingBell;
  250.   Halt;
  251. end;
  252.  
  253. procedure DialogBox(S : String);
  254.  
  255. var
  256.   Win : StackWindow;
  257.   XY, SL : Word;
  258.  
  259. begin
  260.   if not Win.InitCustom(PrX1, PrY1, PrX2, PrY1 + 2,
  261.                         ESColors, wClear+wBordered(*+wSoundEffects*)) then
  262.     Abort('Error initializing prompt window');
  263.   with Win do begin
  264.     EnableExplosions(5);
  265.     GetCursorState(XY, SL);
  266.     Draw;
  267.     HiddenCursor;
  268.     wFastCenter(S, 1, ESColors.TextColor);
  269.     wFastCenter('Press any key when ready', 2, ESColors.TextColor);
  270.     if ReadKey = #0 then ;
  271.     Erase;
  272.     RestoreCursorState(XY, SL);
  273.     Done;
  274.   end;
  275. end;
  276.  
  277. function PromptUser(Prompt : String; MaxLen : Byte) : String;
  278.  
  279. var
  280.   Win : StackWindow;
  281.   XY, SL : Word;
  282.   SLE : SimpleLineEditor;
  283.   S   : String;
  284. begin
  285.   PromptUser := '';
  286.   if not Win.InitCustom(PrX1, PrY1, PrX2, PrY1 + 2,
  287.                         ESColors, wClear+wBordered(*+wSoundEffects*)) then
  288.     Abort('Error initializing prompt window');
  289.   with Win do begin
  290.     EnableExplosions(5);
  291.     Draw;
  292.     if not SLE.Init(EsColors) then
  293.       Exit;
  294.     S := '';
  295.     SLE.ReadString(Prompt, PrY1 + 1, PrX1 + 2, MaxLen,
  296.                    (PrX2 - PrX1) - (Length(Prompt) + 2), S);
  297.     if (SLE.GetLastCommand = ccQuit) then
  298.       Exit;
  299.     PromptUser := S;
  300.     SLE.Done;
  301.     Erase;
  302.     Done;
  303.   end;
  304. end;
  305.  
  306. function YesOrNo(Prompt : String;
  307.                  Row, Col : Byte;
  308.                  Default : Char) : Boolean;
  309. var
  310.   P : Byte;
  311.   C : Char;
  312. begin
  313.   Default := Upcase(Default);
  314.   P := Length(Prompt) + 3;
  315.   Prompt := Prompt + ' [' + Default + ']';
  316.   GotoXYAbs(Col + (Length(Prompt) - 2), Row);
  317.   FastWrite(Prompt, Row, Col, NormalAttr);
  318.   repeat
  319.     C := UpCase(Char(GetKey));
  320.   until C in ['N','Y',^M, ^[];
  321.   if C = ^M then
  322.     C := Default
  323.   else if C = ^[ then
  324.     C := 'N';
  325.   FastWrite(C, Row, Col + P - 1, NormalAttr);
  326.   YesOrNo := C = 'Y';
  327. end;
  328.  
  329. function PromptYesOrNo(Prompt : String; Default : Boolean) : Boolean;
  330.  
  331. var
  332.   Win : StackWindow;
  333.   XY, SL : Word;
  334.   C   : Char;
  335.   S   : String;
  336. begin
  337.   PromptYesOrNo := Default;
  338.   if not Win.InitCustom(PrX1, PrY1, PrX2, PrY1 + 2,
  339.                         ESColors, wClear+wBordered(*+wSoundEffects*)) then
  340.     Abort('Error initializing prompt window');
  341.   with Win do begin
  342.     EnableExplosions(5);
  343.     GetCursorState(XY, SL);
  344.     Draw;
  345.     NormalCursor;
  346.     if Default then
  347.       C := 'Y'
  348.     else
  349.       C := 'N';
  350.     PromptYesOrNo := YesOrNo(Prompt, PrY1 + 1, PrX1 + 2, C);
  351.  
  352.     Erase;
  353.     Done;
  354.     RestoreCursorState(XY, SL);
  355.   end;
  356. end;
  357.  
  358. function BiosPrinterStatus(LPTNo : LPTType) : Byte;
  359.   {-Call BIOS Printer Status function for specified LPT number}
  360. var
  361.   Regs : Registers;
  362. begin
  363.   with Regs do begin
  364.     AH := 2;
  365.     DX := Word(LPTNo);
  366.     Intr($17, Regs);
  367.     BiosPrinterStatus := AH;
  368.   end;
  369. end;
  370.  
  371. procedure TestSequence(LPTNo : LPTType; var Results : ResultType);
  372.   {-Perform the BIOS Printer tests}
  373. var
  374.   Test : TestType;
  375.  
  376. begin
  377.   for Test := Online to PoweredOff do begin
  378.     DialogBox(TestPrompt[Test]);
  379.     Results[Test] := BiosPrinterStatus(LPTNo);
  380.   end;
  381. end;
  382.  
  383. function FindAndScoreMask(Results : ResultType; var Mask : Byte) : Word;
  384.   {-Find best mask value and score its effectiveness}
  385. var
  386.   Sc, M, I, HighSc, HighIndex : Byte;
  387. const
  388.   Masks : Array[1..3] of Byte = ($90, $10, $A0);
  389.  
  390. begin
  391.   HighSc := 0;
  392.   HighIndex := 1;
  393.   for I := 1 to 3 do begin
  394.     M  := Masks[I];
  395.     Sc := 0;
  396.     if M and Results[Online] = M then
  397.       Sc := OnlineWeight;
  398.     if M and Results[Offline] <> M then
  399.       Sc := Sc + OfflineWeight;
  400.     if M and Results[OutOfPaper] <> M then
  401.       Sc := Sc + PaperWeight;
  402.     if M and Results[PoweredOff] <> M then
  403.       Sc := Sc + OffWeight;
  404.     if Sc > HighSc then begin
  405.       HighIndex := I;
  406.       HighSc    := Sc;
  407.     end;
  408.   end;
  409.   FindAndScoreMask := HighSc;
  410.   Mask := Masks[HighIndex];
  411. end;
  412.  
  413. function PickBiosTest(LPTNo : LPTType;
  414.                       var Mask : Byte; var HighScore : Byte) : Byte;
  415.   {-Perform test and analyze results}
  416.  
  417. var
  418.   Score            : Array[1..4] of Byte;
  419.   Results          : ResultType;
  420.   Test             : TestType;
  421.   Sc, TestNo, I    : Byte;
  422. begin
  423.   {perform the printer tests}
  424.   TestSequence(LPTNo, Results);
  425.  
  426.   {calculate score for each type of printer test}
  427.   Sc := 0;
  428.   if PrnTest1Prim(Word(Results[Online])) then
  429.     Sc := OnlineWeight;
  430.   if not PrnTest1Prim(Word(Results[Offline])) then
  431.     Sc := Sc + OfflineWeight;
  432.   if not PrnTest1Prim(Word(Results[OutOfPaper])) then
  433.     Sc := Sc + PaperWeight;
  434.   if not PrnTest1Prim(Word(Results[PoweredOff])) then
  435.     Sc := Sc + OffWeight;
  436.   Score[1] := Sc;
  437.  
  438.   Sc := 0;
  439.   if PrnTest2Prim(Word(Results[Online])) then
  440.     Sc := OnlineWeight;
  441.   if not PrnTest2Prim(Word(Results[Offline])) then
  442.     Sc := Sc + OfflineWeight;
  443.   if not PrnTest2Prim(Word(Results[OutOfPaper])) then
  444.     Sc := Sc + PaperWeight;
  445.   if not PrnTest2Prim(Word(Results[PoweredOff])) then
  446.     Sc := Sc + OffWeight;
  447.   Score[2] := Sc;
  448.  
  449.   Sc := 0;
  450.   if PrnTest3Prim(Word(Results[Online])) then
  451.     Sc := OnlineWeight;
  452.   if not PrnTest3Prim(Word(Results[Offline])) then
  453.     Sc := Sc + OfflineWeight;
  454.   if not PrnTest3Prim(Word(Results[OutOfPaper])) then
  455.     Sc := Sc + PaperWeight;
  456.   if not PrnTest3Prim(Word(Results[PoweredOff])) then
  457.     Sc := Sc + OffWeight;
  458.   Score[3] := Sc;
  459.  
  460.   Score[4] := FindAndScoreMask(Results, Mask);
  461.  
  462.   {find HighScore score and record test number}
  463.   HighScore := Score[1];
  464.   TestNo  := 1;
  465.   for I := 2 to 4 do
  466.     if Score[I] > HighScore then begin
  467.       HighScore := Score[I];
  468.       TestNo  := I;
  469.     end;
  470.  
  471.   {if our best score isn't better than a cutoff, then use no test}
  472.   if HighScore < (OnlineWeight + 1) then
  473.     TestNo := 0;
  474.  
  475.   PickBiosTest := TestNo;
  476. end;
  477.  
  478. function InitEntryScreen : Word;
  479.   {-Initialize entry screen generated by MAKESCRN}
  480. const
  481.   Frame1 = '╓╙╖╜──║║';
  482.   WinOptions = wBordered+wClear+wUserContents(*+wSoundEffects*);
  483. begin
  484.   with EntryCommands do begin
  485.     AddCommand(ccUser0, 1, $4400, 0);
  486.     AddCommand(ccUser1, 1, $2D00, 0);
  487.   end;
  488.   with ES do begin
  489.     if not InitCustom(5, 9, 75, 16, EsColors, WinOptions) then begin
  490.       InitEntryScreen := InitStatus;
  491.       Exit;
  492.     end;
  493.     wFrame.SetFrameType(Frame1);
  494.     EnableExplosions(5);
  495.     wFrame.AddShadow(shBR, shSeeThru);
  496.     wFrame.AddHeader('Printer Information', heTC);
  497.     SetWrapMode(WrapAtEdges);
  498.  
  499.     SetPreEditProc(PreEdit);
  500.     SetPostEditProc(PostEdit);
  501.     SetErrorProc(ErrorHandler);
  502.     EntryCommands.SetHelpProc(DisplayHelp);
  503.  
  504.  
  505.   {idUseBiosServices:}
  506.     AddBooleanField(
  507.       'Use BIOS Services :', 2, 2,
  508.       'B', 2, 25,
  509.       hiUseBiosServices, UserRec.UseBiosServices);
  510.  
  511.   {idPrinterName:}
  512.     esFieldOptionsOn(efClearFirstChar);
  513.     AddStringField(
  514.       'Enter name        :', 3, 2,
  515.       CharStr('X', 32), 3, 25, 32,
  516.       hiPrinterName, UserRec.PrinterName);
  517.  
  518.   {idLPTNumber:}
  519.     AddByteField(
  520.       'Enter LPT Number  :', 4, 2,
  521.       '9', 4, 25,
  522.       hiLPTNumber, 1, 3, UserRec.LPTNumber);
  523.  
  524.   {idPrinterTestNo:}
  525.     AddByteField(
  526.       'Enter Printer Test:', 5, 2,
  527.       '9', 5, 25,
  528.       hiPrinterTestNo, 0, 4, UserRec.PrinterTestNo);
  529.  
  530.     InitEntryScreen := GetLastError;
  531.   end;
  532. end;
  533.  
  534. function DoAuto : Byte;
  535. var
  536.   TestNo : Byte;
  537.  
  538. begin
  539.   TestNo := PickBiosTest(LPTType(UserRec.LPTNumber-1), Mask, HighScore);
  540.   if TestNo = 0 then begin
  541.     Sound(110);
  542.     Delay(800);
  543.     NoSound;
  544.     DialogBox('No printer test is adequate! Using test number 0.');
  545.   end;
  546.   DoAuto := TestNo;
  547. end;
  548.  
  549. procedure ProcessPrinter;
  550.   {-Store the stream}
  551.  
  552. var
  553.   Stm : BufIDStream;
  554.   BP  : BasePrinterPtr;
  555.   T   : PrnType;
  556.   ErrorCode : Word;
  557. begin
  558.   with UserRec do
  559.     if UseBiosServices then begin
  560.       BP := New(BiosPrinterPtr, InitCustom(LPTType(LPTNumber-1),
  561.                                            PrinterTestNo,
  562.                                            Mask));
  563.       if BP = NIL then begin
  564.         DialogBox('Unable to create BiosPrinter object');
  565.         Exit;
  566.       end;
  567.     end
  568.     else begin
  569.       if StUpCase(PrinterName) = 'PRN' then
  570.         T := Prn
  571.       else
  572.         T := DiskFile;
  573.       BP := New(DosPrinterPtr, Init(PrinterName, T));
  574.       if BP = NIL then begin
  575.         DialogBox('Unable to create DosPrinter object');
  576.         Exit;
  577.       end;
  578.     end;
  579.   if not Stm.Init(StreamFileName, SCreate, 1024) then begin
  580.     DialogBox('Can not open stream file, aborting...');
  581.     Exit;
  582.   end;
  583.   with Stm do begin
  584.     RegisterHier(DosPrinterStream);
  585.     RegisterHier(BiosPrinterStream);
  586.     PutPtr(BP);
  587.     ErrorCode := GetStatus;
  588.     Done;
  589.   end;
  590.   if ErrorCode = 0 then
  591.     DialogBox('Stream successfully written')
  592.   else
  593.     DialogBox('Error writing stream.  Aborting...');
  594. end;
  595.  
  596. procedure DoEntryScreen;
  597.  
  598. var
  599.   AllDone : Boolean;
  600.   ExitCmd : Word;
  601.  
  602. begin
  603.   {$IFDEF UseMouse}
  604.   if MouseInstalled then
  605.     with EsColors do begin
  606.       {activate mouse cursor}
  607.       SoftMouseCursor($0000, (ColorMono(MouseColor, MouseMono) shl 8)+
  608.                              Byte(MouseChar));
  609.       ShowMouse;
  610.       {enable mouse support}
  611.       EntryCommands.cpOptionsOn(cpEnableMouse);
  612.     end;
  613.   {$ENDIF}
  614.  
  615.   {initialize entry screen}
  616.   Status := InitEntryScreen;
  617.   if Status <> 0 then begin
  618.     WriteLn('Error initializing entry screen: ', Status);
  619.     Halt(1);
  620.   end;
  621.  
  622.   {initialize user record}
  623.   FillChar(UserRec, SizeOf(UserRec), 0);
  624.   with UserRec do begin
  625.     UseBiosServices := True;
  626.     LPTNumber := 1;
  627.     PrinterTestNo := 1;
  628.   end;
  629.   ES.ChangeProtection(idPrinterName, True);
  630.   AllDone := False;
  631.   {test entry screen}
  632.   repeat
  633.     ES.Process;
  634.     ExitCmd := ES.GetLastCommand;
  635.     case ExitCmd of
  636.       ccQuit   : AllDone :=
  637.                    PromptYesOrNo('Really exit without saving?', False);
  638.       ccError  : begin
  639.                    AllDone := True;
  640.                    DialogBox('An error has occurred processing the entry screen');
  641.                  end;
  642.       ccUser1  : AllDone := True;
  643.       ccDone   : begin
  644.                    ProcessPrinter;
  645.                    AllDone := True;
  646.                  end;
  647.       ccUser0  : if ES.GetCurrentID = idPrinterTestNo then begin
  648.                    UserRec.PrinterTestNo := DoAuto;
  649.                    ES.SetLastCommand(ccNextField);
  650.                  end;
  651.     end;
  652.   until AllDone;
  653.  
  654.   ES.Erase;
  655.   ES.Done;
  656.  
  657.   {$IFDEF UseMouse}
  658.   HideMouse;
  659.   {$ENDIF}
  660. end;
  661.  
  662. function GetStreamName : Boolean;
  663.  
  664. begin
  665.   GetStreamName := False;
  666.   WriteHelpLine('Enter the name of the stream file to create');
  667.   StreamFileName := PromptUser('File name: ', SizeOf(StreamFileName) - 1);
  668.   if ExistFile(StreamFileName) then
  669.     if not PromptYesOrNo('File exists, overwrite?', False) then
  670.       Exit;
  671.   GetStreamName := StreamFileName <> '';
  672. end;
  673.  
  674. begin
  675.   TextChar := '░';
  676.   ClrScr;
  677.   case CurrentMode of
  678.     2, 7 : begin
  679.              HelpAttr   := ESColors.FlexBHelpMono;
  680.              NormalAttr := ESColors.TextMono;
  681.            end;
  682.     else begin
  683.       HelpAttr   := ESColors.FlexBHelpColor;
  684.       NormalAttr := ESColors.TextColor;
  685.     end;
  686.   end;
  687.   FastWrite(Center(Title, ScreenWidth), 1, 1, HelpAttr);
  688.   HelpLine := ScreenHeight;
  689.   ClearHelpLine;
  690.   if GetStreamName then
  691.     DoEntryScreen;
  692.   TextAttr := $07;
  693.   ClrScr;
  694. end.
  695.